//
//  VideoPlayer.m
//  HappyBaby
//
//  Created by 华哥 on 15/11/24.
//  Copyright © 2015年 华哥. All rights reserved.
//

#import "VideoPlayer.h"
#import <AVFoundation/AVFoundation.h>
#import "VideoProgress.h"
#import "Define.h"

@interface VideoPlayer () <AVAudioPlayerDelegate>


@property (nonatomic, strong) NSTimer *timer;

@end

@implementation VideoPlayer

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        float scaleX = kScreenWidth / 375;
        float scaleY = kScreenHeight / 667;
//        播放器;
        self.avAudioPlayer = [[AVAudioPlayer alloc]init];
        
//        播放暂停按钮
        self.playAndPause = [UIButton buttonWithType:UIButtonTypeCustom];
        self.playAndPause.frame = CGRectMake(250 * scaleX, 27.5 * scaleY, 30 * scaleX, 30 * scaleY);
        [self.playAndPause setImage:[[UIImage imageNamed:@"iconfont-bofang"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
        [self addSubview:_playAndPause];
        
//        下一首按钮;
        self.nextButon = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        self.nextButon.frame = CGRectMake(300 * scaleX, 30 * scaleY, 25 * scaleX, 25 * scaleY);
        [self.nextButon setImage:[[UIImage imageNamed:@"iconfont-xiayishou"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]  forState:UIControlStateNormal];
        [self addSubview:_nextButon];
        
//        上一首
        self.beforeButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        self.beforeButton.frame = CGRectMake(200 * scaleX, 30 * scaleY, 25 * scaleX, 25 * scaleY);
        [self.beforeButton setImage:[[UIImage imageNamed:@"iconfont-shangyishou"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
        [self addSubview:_beforeButton];
        
        self.videoProgress = [[VideoProgress alloc]initWithFrame:CGRectMake(20 * kScreenWidth / 375, 0, kScreenWidth - 40 * kScreenWidth / 375, 50 * kScreenWidth / 667)];
        [self addSubview:_videoProgress];
        
        self.namelabel = [[UILabel alloc]initWithFrame:CGRectMake(20 * scaleX, 25 * scaleY, 120 * scaleX, 30 * scaleY)];
        self.namelabel.font = [UIFont systemFontOfSize:12 * scaleX weight:0.5];
        self.namelabel.text = @"HappyBaby";
        self.namelabel.textAlignment = NSTextAlignmentCenter;
        self.namelabel.textColor = [UIColor colorWithRed:242 / 255.0 green:98 / 255.0 blue:11 / 255.0 alpha:1];
        
        
        [self addSubview:_namelabel];
        
        self.timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(140 * scaleX, 25 * scaleY, 50 * scaleX, 30 * scaleY)];
        self.timeLabel.font = [UIFont systemFontOfSize:10 weight:0.5];
        self.timeLabel.text = @"00:00";
        [self addSubview:self.timeLabel];
    }
    return self;
}




























@end
